//
//  UIButton+XDButton.m
//  ocweibo
//
//  Created by lucy on 2016/10/24.
//  Copyright © 2016年 com.huashengHuaSheng. All rights reserved.
//

#import "UIButton+XDButton.h"

@implementation UIButton (XDButton)

+ (instancetype)setImageName:(NSString*)imageName andBackgroundImgName:(NSString*)backgroundImgName andTitle:(NSString*)title andTitleFontSize:(CGFloat)titleSize andTitleColor:(UIColor*)titleColor{
//    
//        UIButton* btn = [[self alloc]init];
//
//        //按钮图片
//        [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
//        [btn setImage:[UIImage imageNamed:[imageName stringByAppendingString:@"_highlighted"]] forState:UIControlStateHighlighted];
//    
//        //按钮背景图片
//        [btn setBackgroundImage:[UIImage imageNamed:backgroundImgName] forState:UIControlStateNormal];
//        [btn setBackgroundImage:[UIImage imageNamed:[backgroundImgName stringByAppendingString:@"_highlighted"]] forState:UIControlStateHighlighted];
//    
//        [btn setTitle:title forState:UIControlStateNormal];
//        [btn setTintColor:titleColor];
//        btn.titleLabel.font = [UIFont systemFontOfSize:titleSize];
//        [btn sizeToFit];
    

    return nil;
}


+ (instancetype)setHighlightName:(NSString*)highName title:(NSString*)title target:(id)target action:(SEL_Nonnull)action{

    UIButton* btn = [[UIButton alloc]init];
    if (highName) {
        [btn setImage:[UIImage imageNamed:highName] forState:UIControlStateNormal];
        [btn setImage:[UIImage imageNamed:[highName stringByAppendingString:@"_highlighted"]] forState:UIControlStateHighlighted];
    }
    if (title) {
        [btn setTitle:title forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor orangeColor] forState:UIControlStateHighlighted];
        btn.titleLabel.font = [UIFont systemFontOfSize:14];
    }
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    [btn sizeToFit];
}

@end
























